<body>
    <h1>最新电影</h1>
    <button>获取</button>
    <ul></ul>
    <script src="../llllllxxxxxx/ajax-promise.js"></script>
    <script>
        // 1 获取按钮，绑定点击事件
        let btnObj = document.querySelector('button')
        btnObj.onclick = function () {
            console.log('拿到数据：')
            // 3 事件处理函数 - 拿到数据 
            get('https://m.maizuo.com/gateway',
                // 'cityId=310100&pageNum=1&pageSize=10&type=1&k=3576785'
                {cityId:110100,
                    pageNum:1,
                    pageSize:10,
                    type:1,
                    k:9390772
                },
                'json',
                {'X-Client-Info':'{"a":"3000","ch":"1002","v":"5.2.0","e":"16525006601241743764750337","bc":"110100"}',
                'X-Host': 'mall.film-ticket.film.list',
                'X-Requested-With':'XMLHttpRequest',
                'X-Token':'undefined'}
            )
            .then(
                res=>{
                    
                    let ulObj = document.querySelector('ul')
                    ulObj.innerText = ''
                    res.data.films.forEach(item => {
                    let liObj = document.createElement('li')
                    liObj.innerHTML = `${item.filmId} - ${item.name}<img src="${item.poster}" />`
                    ulObj.appendChild(liObj)
                    }) 
                }
            )
            .catch(
                err=>{
                    console.log('失败',err);
                }
            )
            .finally(
                console.log(1)
            )
        }


    </script>
</body>